//
//  HWMeViewController.m
//  嗨文
//
//  Created by 响当当 on 2019/1/8.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWMeViewController.h"
#import "HWMyInformationVIew.h"

@interface HWMeViewController ()
@property (nonatomic, strong)HWMyInformationVIew *myInformationView;
@end

@implementation HWMeViewController

#pragma mark - init
- (instancetype)init
{
    if ([super init])
    {
        [self.view setBackgroundColor:LCHexColor(0xffffff)];
    }
    return [super init];
}


- (HWMyInformationVIew *)myInformationView
{
    if (!_myInformationView)
    {
        _myInformationView = [[HWMyInformationVIew alloc]initWithFrame:CGRectMake(0,NAVIBAR_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT- NAVIBAR_HEIGHT -TABBAR_HEIGHT)];
    }
    return _myInformationView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"我的"];
    
    [self.view addSubview:self.myInformationView];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self buryPoint];
    [self getInfor];
}

#pragma mark - 获取我的个人信息数据
- (void)getInfor
{
    
    NSDictionary *prarmers = @{
                               @"access_token" : current_User.token                               };
    
    [MyInfoManager getMyInfo:prarmers sucess:^(id  _Nonnull acceptData) {
         DISMISS_SVP(1.0f);
        HWMyinformationModel *model = [[HWMyinformationModel alloc]initWithDic:acceptData];
        [self.myInformationView getMyInformation:model];

    } fail:^(NSError * _Nullable error) {
        DISMISS_SVP(1.0f);
        [SVProgressHUD showErrorWithStatus:@"获取个人信息失败，请检查网络是否良好"];
        DISMISS_SVP(1.0f);
    }];
}

- (void)buryPoint
{
    NSString *lastStayTime = [kUserDefaults objectForKey:@"time"];
    NSString *nowStayTime = [NSString stringWithFormat:@"%ld",[[HWUtilties getNowTimeTimestamp3] integerValue] - lastStayTime.integerValue];
    
    [HWUtilties buryPointWithStayTime:nowStayTime
                            timestamp:[HWUtilties getNowTimeTimestamp3]
                             memberId:current_User.userID
                              fromUrl:self.fromUrl
                                toUrl:@"/personal"
                               fromId:self.fromId
                                 toId:@"2893ecaa8bb29bd3"];
}

@end
